﻿namespace Lilium.Web.ReactiveHtml

type HtmlTag = Table | CustomTag of string

type HtmlAttribute = Id of string | CustomAttribute of (string * string) // name * value

type IHtmlFormatter =
    abstract member openTag : 
        HtmlTag 
        -> IHtmlFormatter

    abstract member attribute : 
        HtmlAttribute 
        -> IHtmlFormatter

    abstract member closeTag : 
        unit
        -> IHtmlFormatter

module HtmlFormatterUtils =
    
    let tagName = function 
        | Table -> "table"
        | CustomTag name -> name

    let attributeNameAndValue = function
        | Id value -> ("id", value)
        | CustomAttribute nameAndValue -> nameAndValue

module Html =
    
    let table = fun (k : IHtmlFormatter) -> k.openTag(Table).closeTag()